<%= form_for(bill) do |f| %>
    <div class="form-group">
        <%= f.label :name %>
        <%= f.text_field :name, class: "form-control", placeholder: "bill name" %>
    </div>
    <div class="form-group">
        <%= f.label :description %>
        <%= f.text_field :description, class: "form-control", placeholder: "bill description" %>
    </div>
    <div class="form-group">
        <%= f.label :member %>
        <div class="checkbox">

            <% current_group_users.each do |user| %>
                <label>
                    <% if edit_tag %>
                        <% if @bill.user_id == user.id %>
                            <%= check_box_tag "members", user.name,  member_ids.include?(user.id), {name: "bill[members][#{user.id}]", class: "select-check-box"} %>
                        <% else %>
                            <%= check_box_tag "members", user.name, member_ids.include?(user.id), {name: "bill[members][#{user.id}]"} %>
                        <% end %>
                    <% else %>
                        <% if current_user.id == user.id %>
                            <%= check_box_tag "members", user.name, current_user.id == user.id, {name: "bill[members][#{user.id}]", class: "select-check-box"} %>
                        <% else %>
                            <%= check_box_tag "members", user.name, current_user.id == user.id, {name: "bill[members][#{user.id}]"} %>
                        <% end %>
                    <% end %>
                    <%= user.name %>
                </label>
            <% end %>
        </div>
    </div>
    <div class="form-group">
        <%= f.label :amount %>
        <%= f.text_field :amount, class: "form-control", placeholder: "total price" %>
    </div>
    <%= f.submit "Submit", class: "btn btn-primary submit" %>
<% end %>
<script type="text/javascript">
    $(".select-check-box").click(function () {
        this.checked = "checked"
    })
    $("form").validate({
        rules: {
            "bill[description]": "required",
            "bill[amount]": "required"
        }
    });
</script>